﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Xml.Linq;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.LIB;

namespace HangerSupport
{
	public partial class DlgHSDesign : System.Windows.Forms.Form
	{
		public DlgHSDesign(ref HSTypeInfo HSTypeManage, ref PipeSelect secSelectInfo, UIApplication uiApp, bool bSelectPipesSection = false)
		{
			this.InitializeComponent();
			YJKProcessTools hyprocessTools = new YJKProcessTools();
			hyprocessTools.ShowInTaskbarChange(this);
			this.m_uiApp = uiApp;
			this.m_doc = uiApp.ActiveUIDocument.Document;
			this.m_HSTypeManage = HSTypeManage;
			this.m_secSelectInfo = secSelectInfo;
			this.m_selHSDefineInfo = this.m_HSTypeManage.GetDefaultType();
			this.m_kDrawType = HSDrawType.eDrawTypeDrawSingle;
			this.m_dElevation = 0.0;
			this.m_selHSDefineInfo.m_bChangeOnlyBaseHigh = false;
			this.pictureBox = new DrawPreviewer(0u);
			this.pictureBox.SetConstPenWide(false);
			this.pictureBox.Paint += this.picturePaint;
			this.picViewBox.Controls.Add(this.pictureBox);
			this.pictureBox.Dock = DockStyle.Fill;
			this.pictureBox.BackColor = System.Drawing.Color.White;
			this.pictureBox.BorderStyle = BorderStyle.FixedSingle;
			this.pictureBox.SizeMode = PictureBoxSizeMode.AutoSize;
			this.pictureBox.TabStop = false;
			this.m_colorPen = PenColor.PC_Green;
			this.m_colorText = PenColor.PC_Red;
			this.m_dFontHigh = 50.0;
			this.m_listLevel = new List<Level>();
			FilteredElementCollector filteredElementCollector = new FilteredElementCollector(this.m_uiApp.ActiveUIDocument.Document);
			ICollection<Element> collection = filteredElementCollector.OfClass(typeof(Level)).ToElements();
			foreach (Element element in collection)
			{
				Level level = element as Level;
				bool flag = level != null;
				if (flag)
				{
					this.m_listLevel.Add(level);
				}
			}
			this.m_hsPropManage = new HSPropsLst(this.m_listLevel);
			this.m_curLevel = null;
			bool flag2 = this.m_uiApp.ActiveUIDocument.Document != null;
			if (flag2)
			{
				this.m_curLevel = this.m_uiApp.ActiveUIDocument.Document.ActiveView.GenLevel;
			}
			bool flag3 = this.m_curLevel != null;
			if (flag3)
			{
				this.m_selHSDefineInfo.m_strElevationName = this.m_curLevel.Name;
			}
			this.m_ptBase = this.m_selHSDefineInfo.m_ptBase;
			this.m_secSelectInfo.m_bMirrored = this.m_selHSDefineInfo.m_bMirrored;
			this.m_secSelectInfo.GetSecInfoFromSelPipes();
			this.m_bSelectPipesSection = bSelectPipesSection;
			this.AutoAdjustHSSectionSize(this.m_kDrawType, this.m_bSelectPipesSection);
			this.DrawSection();
			this.SetPropDefine();
			bool flag4 = DlgHSDesign.g_Dlg_X > 0;
			if (flag4)
			{
				base.Location = new System.Drawing.Point(DlgHSDesign.g_Dlg_X, DlgHSDesign.g_Dlg_Y);
			}
			else
			{
				base.StartPosition = FormStartPosition.CenterParent;
			}
		}

		private void DlgHSDesign_FormClosed(object sender, FormClosedEventArgs e)
		{
			DlgHSDesign.g_Dlg_X = base.Location.X;
			DlgHSDesign.g_Dlg_Y = base.Location.Y;
		}

		public void GetConfigXML()
		{
			string text = "";
			bool flag = !File.Exists(text);
			if (flag)
			{
				XElement xelement = new XElement("HYUserConfig");
				xelement.Save(text);
			}
		}

		private void picturePaint(object sender, PaintEventArgs e)
		{
			Graphics graphics = e.Graphics;
			graphics.Clear(System.Drawing.Color.Black);
			this.RefreshPreview(graphics);
		}

		private void btnSelect_Click(object sender, EventArgs e)
		{
			this.SelectHSType();
		}

		public void SelectHSType()
		{
			SizeViewType kViewType = this.m_selHSDefineInfo.m_kViewType;
			DlgHSSelect dlgHSSelect = new DlgHSSelect(this.m_HSTypeManage, this.m_selHSDefineInfo);
			bool flag = DialogResult.OK != dlgHSSelect.ShowDialog();
			if (!flag)
			{
				HSType eType = this.m_selHSDefineInfo.m_eType;
				this.m_selHSDefineInfo = dlgHSSelect.GetSelect();
				this.m_selHSDefineInfo.m_kViewType = kViewType;
				this.m_selHSDefineInfo.m_bChangeOnlyBaseHigh = false;
				bool flag2 = eType == this.m_selHSDefineInfo.m_eType;
				if (!flag2)
				{
					this.SetPropDefine();
					this.AutoAdjustHSSectionSize(this.m_kDrawType, true);
					this.DrawSection();
					this.pictureBox.ZoomExtents();
				}
			}
		}

		public HSDefineInfo GetSelHS()
		{
			return this.m_selHSDefineInfo;
		}

		public void SetSelHS(HSDefineInfo def)
		{
			this.m_selHSDefineInfo = def;
		}

		private void AddLine(double dX1, double dY1, double dX2, double dY2, PenColor colorCur = PenColor.PC_Red, double dPenWide = 20.0)
		{
			XYZ pt = new XYZ(dX1, dY1, 0.0);
			XYZ pt2 = new XYZ(dX2, dY2, 0.0);
			this.AddLine(pt, pt2, colorCur, dPenWide);
		}

		private void AddLine(XYZ pt1, XYZ pt2, PenColor colorCur = PenColor.PC_Red, double dPenWide = 20.0)
		{
			bool flag = pt1.DistanceTo(pt2) <= 0.0;
			if (!flag)
			{
				Line curve = Line.CreateBound(pt1, pt2);
				this.m_lstViewCurves.Add(new CurveInfo(curve, colorCur, (float)dPenWide));
			}
		}

		private void AddLine(Line lineIn, PenColor colorCur = PenColor.PC_Red, double dPenWide = 20.0)
		{
			XYZ endPoint = lineIn.GetEndPoint(0);
			XYZ endPoint2 = lineIn.GetEndPoint(1);
			this.AddLine(endPoint, endPoint2, colorCur, dPenWide);
		}

		private void AddCircle(double dX, double dY, double dRadius, PenColor colorCur = PenColor.PC_Red, double dPenWide = 20.0)
		{
			bool flag = dRadius <= 0.0;
			if (!flag)
			{
				XYZ xyz = new XYZ(1.0, 0.0, 0.0);
				XYZ xyz2 = new XYZ(0.0, 1.0, 0.0);
				double num = 0.0;
				double num2 = Math.PI;
				XYZ xyz3 = new XYZ(dX, dY, 0.0);
				Arc curve = Arc.Create(xyz3, dRadius, num, num2, xyz, xyz2);
				Arc curve2 = Arc.Create(xyz3, dRadius, num2 - 0.5, 2.0 * num2 + 0.5, xyz, xyz2);
				this.m_lstViewCurves.Add(new CurveInfo(curve, colorCur, (float)dPenWide));
				this.m_lstViewCurves.Add(new CurveInfo(curve2, colorCur, (float)dPenWide));
			}
		}

		private void AddCircle(XYZ ptC, double dRadius, PenColor colorCur = PenColor.PC_Red, double dPenWide = 20.0)
		{
			this.AddCircle(ptC.X, ptC.Y, dRadius, colorCur, dPenWide);
		}

		private void AddEllipse(double dX, double dY, double dRadiusX, double dRadiusY, PenColor colorCur = PenColor.PC_Red, double dPenWide = 20.0)
		{
			bool flag = dRadiusX <= 0.0 || dRadiusY <= 0.0;
			if (!flag)
			{
				bool flag2 = true;
				bool flag3 = Math.Abs(dRadiusY - dRadiusX) < 1.0;
				if (flag3)
				{
					this.AddCircle(dX, dY, dRadiusX, colorCur, dPenWide);
				}
				else
				{
					bool flag4 = dRadiusX < dRadiusY;
					if (flag4)
					{
						flag2 = false;
						double num = dRadiusX;
						dRadiusX = dRadiusY;
						dRadiusY = num;
					}
					XYZ xyz = new XYZ(1.0, 0.0, 0.0);
					XYZ xyz2 = new XYZ(0.0, 1.0, 0.0);
					Line line = Line.CreateBound(new XYZ(dRadiusX, 0.0, 0.0), new XYZ(-dRadiusX, 0.0, 0.0));
					Line line2 = Line.CreateUnbound(new XYZ(0.0, dRadiusY, 0.0), XYZ.BasisY);
					XYZ xyz3 = new XYZ(dRadiusX, dRadiusY, 0.0);
					XYZ xyz4 = new XYZ(0.0, 0.0, 1.0);
					double length = xyz3.GetLength();
					double num2 = dRadiusX - dRadiusY;
					double num3 = (length - num2) / 2.0;
					xyz3 = xyz3.Normalize();
					XYZ xyz5 = xyz3 * num3;
					XYZ xyz6 = new XYZ(-dRadiusX, 0.0, 0.0) + xyz5;
					XYZ xyz7 = xyz4.CrossProduct(xyz3) * 1000.0;
					Line line3 = Line.CreateUnbound(xyz6, xyz7);
					IntersectionResultArray intersectionResultArray;
					IntersectionResultArray intersectionResultArray2 = null;
                    bool flag5 = line3.Intersect(line, out intersectionResultArray) != (SetComparisonResult)(8) 
                        || line3.Intersect(line2, out intersectionResultArray2) != (SetComparisonResult)(8);
					if (!flag5)
					{
						XYZ xyz8 = intersectionResultArray.get_Item(0).XYZPoint;
						XYZ xyz9 = intersectionResultArray2.get_Item(0).XYZPoint;
						double num4 = xyz.AngleOnPlaneTo(xyz7, XYZ.BasisZ);
						double num5 = Math.PI*2 - num4;
						double num6 = Math.PI - num4;
						double num7 = -num6;
						double num8 = Math.Abs(dRadiusX - Math.Abs(xyz8.X));
						double num9 = Math.Abs(dRadiusY + Math.Abs(xyz9.Y));
						XYZ xyz10 = new XYZ(dX, dY, 0.0);
						bool flag6 = !flag2;
						if (flag6)
						{
							double num10 = num8;
							num8 = num9;
							num9 = num10;
							double x = xyz8.X;
							double y = xyz9.Y;
							xyz8 = new XYZ(y, 0.0, 0.0);
							xyz9 = new XYZ(0.0, x, 0.0);
							num4 = 4.71238898038469 - num4;
							num5 = Math.PI*2 - num4;
							num6 = Math.PI - num4;
							num7 = -num6;
							xyz8 *= -1.0;
							xyz9 *= -1.0;
						}
						Arc curve = Arc.Create(xyz10 + xyz8, num8, num4, num5, xyz, xyz2);
						Arc curve2 = Arc.Create(xyz10 - xyz8, num8, num7, num6, xyz, xyz2);
						Arc curve3 = Arc.Create(xyz10 + xyz9, num9, num6, num4, xyz, xyz2);
						Arc curve4 = Arc.Create(xyz10 - xyz9, num9, num5, Math.PI*2 + num7, xyz, xyz2);
						this.m_lstViewCurves.Add(new CurveInfo(curve, colorCur, (float)dPenWide));
						this.m_lstViewCurves.Add(new CurveInfo(curve2, colorCur, (float)dPenWide));
						this.m_lstViewCurves.Add(new CurveInfo(curve3, colorCur, (float)dPenWide));
						this.m_lstViewCurves.Add(new CurveInfo(curve4, colorCur, (float)dPenWide));
					}
				}
			}
		}

		private void AddText(double dX, double dY, string strText, bool bIsVer = false, PenColor colorCur = PenColor.PC_Red, double dFontHigh = 50.0, TextNoteInfo.AlignHType kHorAlignType = TextNoteInfo.AlignHType.AHT_Center, TextNoteInfo.AlignVType kVerAlignType = TextNoteInfo.AlignVType.AVT_Bottom)
		{
			XYZ pos = new XYZ(dX, dY, 0.0);
			double boundingBoxWidth = 1.0;
			double boundingBoxHeight = 1.0;
			double angle = 0.0;
			if (bIsVer)
			{
				angle = 4.71238898038469;
			}
			TextNoteInfo item = new TextNoteInfo(strText, colorCur, dFontHigh, pos, kHorAlignType, kVerAlignType, boundingBoxWidth, boundingBoxHeight, angle);
			this.m_lstViewTexts.Add(item);
		}

		private void AddText(XYZ pt, string strText, bool bIsVer = false, PenColor colorCur = PenColor.PC_Red, double dFontHigh = 50.0, TextNoteInfo.AlignHType kHorAlignType = TextNoteInfo.AlignHType.AHT_Center, TextNoteInfo.AlignVType kVerAlignType = TextNoteInfo.AlignVType.AVT_Bottom)
		{
			this.AddText(pt.X, pt.Y, strText, bIsVer, colorCur, dFontHigh, kHorAlignType, kVerAlignType);
		}

		private void AddBaseLine(XYZ ptBase, XYZ vectDir, double dBarThick = 40.0, PenColor colorCur = PenColor.PC_Gray)
		{
			double dPenWide = 2.0;
			double dPenWide2 = 0.0;
			double num = 30.0;
			double num2 = 20.0;
			XYZ xyz = new XYZ(0.0, 0.0, 1.0);
			XYZ xyz2 = vectDir.CrossProduct(xyz);
			double num3 = dBarThick / 2.0 + num;
			XYZ pt = ptBase + xyz2 * num3;
			XYZ xyz3 = ptBase - xyz2 * num3;
			this.AddLine(pt, xyz3, colorCur, dPenWide);
			double num4 = 5.0;
			int num5 = (int)(num3 * 2.0 / num4);
			XYZ xyz4 = vectDir.Normalize();
			xyz4 += xyz2;
			xyz4 = xyz4.Normalize();
			for (int i = 1; i <= num5; i++)
			{
				this.AddLine(xyz3 + num4 * (double)i * xyz2, xyz3 + num4 * (double)i * xyz2 - num2 * xyz4, colorCur, dPenWide2);
			}
		}

		private void AddLengthDim(XYZ pt1, XYZ pt2, XYZ vectDir, double dVal, string strName = "", PenColor colorText = PenColor.PC_Red, PenColor colorLine = PenColor.PC_Gray)
		{
			bool flag = pt1.DistanceTo(pt2) < 0.1;
			if (!flag)
			{
				dVal = Utils.DoublePrecision(dVal, 1);
				double num = 10.0;
				double num2 = 50.0;
				double num3 = 10.0;
				double num4 = 15.0;
				XYZ xyz = vectDir.Normalize();
				XYZ xyz2 = XYZ.BasisZ.CrossProduct(xyz);
				XYZ xyz3 = (XYZ.BasisX + XYZ.BasisY).Normalize() * num4;
				XYZ xyz4 = pt1 + vectDir * num;
				XYZ xyz5 = pt2 + vectDir * num;
				XYZ xyz6 = xyz4 + vectDir * num2;
				XYZ xyz7 = xyz5 + vectDir * num2;
				XYZ pt3 = xyz6 + vectDir * num3;
				XYZ pt4 = xyz7 + vectDir * num3;
				this.AddLine(xyz4, pt3, colorLine, 0.0);
				this.AddLine(xyz5, pt4, colorLine, 0.0);
				this.AddLine(xyz6, xyz7, colorLine, 0.0);
				this.AddLine(xyz6 + xyz3, xyz6 - xyz3, colorLine, 0.0);
				this.AddLine(xyz7 + xyz3, xyz7 - xyz3, colorLine, 0.0);
				XYZ xyz8 = (xyz6 + xyz7) / 2.0;
				string text = dVal.ToString();
				bool bIsVer = false;
				XYZ xyz9 = XYZ.BasisY;
				bool flag2 = Math.Abs(xyz.X) > 0.0;
				if (flag2)
				{
					bIsVer = true;
					xyz9 = -XYZ.BasisX;
				}
				xyz8 += xyz9 * 25.0;
				SizeViewType kViewType = this.m_selHSDefineInfo.m_kViewType;
				if (kViewType != SizeViewType.kSizeViewName)
				{
					if (kViewType == SizeViewType.kSizeViewSize)
					{
						strName = "";
					}
				}
				else
				{
					text = strName;
					strName = "";
				}
				bool flag3 = strName != "";
				if (flag3)
				{
					text = strName + "=" + text;
				}
				this.AddText(xyz8.X, xyz8.Y, text, bIsVer, this.m_colorText, this.m_dFontHigh, TextNoteInfo.AlignHType.AHT_Center, TextNoteInfo.AlignVType.AVT_Bottom);
			}
		}

		private void AddLevelDim(XYZ pt, XYZ vectDir, double dVal, string strName = "", PenColor colorText = PenColor.PC_Red, PenColor colorLine = PenColor.PC_Gray)
		{
			vectDir = vectDir.Normalize();
			XYZ xyz = vectDir.CrossProduct(XYZ.BasisZ);
			double num = 100.0;
			double num2 = 40.0;
			double num3 = 26.0;
			XYZ xyz2 = pt + vectDir * num3 - xyz * num2;
			XYZ xyz3 = xyz2 + xyz * num2 * 2.0;
			XYZ xyz4 = xyz3 + xyz * num;
			this.AddLine(xyz2, xyz4, colorLine, 0.0);
			this.AddLine(xyz2, pt, colorLine, 0.0);
			this.AddLine(xyz3, pt, colorLine, 0.0);
			XYZ xyz5 = (xyz2 + xyz4) / 2.0 + vectDir * 30.0;
			string text = dVal.ToString();
			bool bIsVer = false;
			bool flag = Math.Abs(vectDir.X) > 0.0;
			if (flag)
			{
				bIsVer = true;
			}
			SizeViewType kViewType = this.m_selHSDefineInfo.m_kViewType;
			if (kViewType != SizeViewType.kSizeViewName)
			{
				if (kViewType == SizeViewType.kSizeViewSize)
				{
					strName = "";
				}
			}
			else
			{
				text = strName;
				strName = "";
			}
			bool flag2 = strName != "";
			if (flag2)
			{
				text = strName + "=" + text;
			}
			this.AddText(xyz5.X, xyz5.Y, text, bIsVer, this.m_colorText, this.m_dFontHigh, TextNoteInfo.AlignHType.AHT_Center, TextNoteInfo.AlignVType.AVT_Bottom);
		}

		private void DrawSection(HSDefineInfo hsDefine)
		{
			this.btnDrawByWall.Enabled = false;
			this.btnDrawBySectionLine.Enabled = true;
			HSType eType = hsDefine.m_eType;
			switch (eType)
			{
			case HSType.kZJ_DC:
				this.DrawSectionZJDC(hsDefine, false);
				break;
			case HSType.kZJ_PX:
				this.DrawSectionZJPX(hsDefine);
				break;
			case HSType.kZJ_SJ:
				this.DrawSectionZJSJ(hsDefine);
				this.btnDrawByWall.Enabled = true;
				break;
			case HSType.kZJ_XB:
				this.DrawSectionZJXB(hsDefine);
				this.btnDrawByWall.Enabled = true;
				break;
			case HSType.kZJ_CB:
				this.DrawSectionZJCB(hsDefine);
				this.btnDrawByWall.Enabled = true;
				this.btnDrawBySectionLine.Enabled = false;
				break;
			case HSType.kZJ_DZ:
				this.DrawSectionZJDZ(hsDefine);
				this.btnDrawByWall.Enabled = true;
				break;
			default:
				switch (eType)
				{
				case HSType.kDJ_DC:
					this.DrawSectionDJDC(hsDefine, false);
					break;
				case HSType.kDJ_PX:
					this.DrawSectionDJPX(hsDefine);
					break;
				case HSType.kDJ_GJ:
					this.DrawSectionDJGJ(hsDefine);
					break;
				case HSType.kDJ_DB:
					this.DrawSectionDJDB(hsDefine);
					this.btnDrawBySectionLine.Enabled = false;
					break;
				case HSType.kDJ_DG:
					this.DrawSectionDJDG(hsDefine);
					this.btnDrawBySectionLine.Enabled = false;
					break;
				case HSType.kDJ_SG:
					this.DrawSectionDJSG(hsDefine);
					break;
				case HSType.kDJ_SL:
					this.DrawSectionDJSL(hsDefine);
					break;
				case HSType.kDJ_ZJ:
					this.DrawSectionDJZJ(hsDefine);
					this.btnDrawByWall.Enabled = true;
					break;
				case HSType.kDJ_YC:
					this.DrawSectionDJYC(hsDefine);
					break;
				case HSType.kDJ_DC3:
					this.DrawSectionDJDC3(hsDefine, false);
					break;
				case HSType.kDJ_PX3:
					this.DrawSectionDJPX3(hsDefine);
					break;
				case HSType.kDJ_DZ:
					this.DrawSectionDJDZ(hsDefine);
					this.btnDrawByWall.Enabled = true;
					break;
				}
				break;
			}
			this.DrawPipeSecSelect();
		}

		private void DrawSectionDJDC3(HSDefineInfo hsDefine, bool bIsPX = false)
		{
			this.DrawSectionDJDC(hsDefine, bIsPX);
		}

		private void DrawSectionDJDC(HSDefineInfo hsDefine, bool bIsPX = false)
		{
			XYZ xyz = new XYZ(100000.0, 100000.0, 0.0);
			xyz = this.m_ptBase;
			XYZ basisX = XYZ.BasisX;
			XYZ basisY = XYZ.BasisY;
			double dHigh = hsDefine.m_matHor.m_dHigh;
			double dHigh2 = hsDefine.m_matVer.m_dHigh;
			double num = hsDefine.m_dNetWide / 2.0;
			double num2 = num + dHigh2 / 2.0;
			XYZ xyz2 = basisX * dHigh2;
			XYZ xyz3 = basisY * dHigh;
			XYZ xyz4 = xyz - basisX * num2 - xyz3 / 2.0;
			XYZ xyz5 = xyz + basisX * num2 - xyz3 / 2.0;
			XYZ xyz6 = xyz4;
			XYZ xyz7 = xyz5;
			this.AddLine(xyz6, xyz7, this.m_colorPen, dHigh);
			for (int i = 1; i < hsDefine.m_nFloorNum; i++)
			{
				XYZ xyz8 = xyz7 + xyz3 / 2.0;
				double num3 = hsDefine.m_dNetHigh[i];
				xyz6 += num3 * basisY + xyz3;
				xyz7 += num3 * basisY + xyz3;
				this.AddLine(xyz6, xyz7, this.m_colorPen, dHigh);
				this.AddLengthDim(xyz8 + xyz2, xyz7 + xyz2 - xyz3 / 2.0, XYZ.BasisX, num3, "净高" + i.ToString(), PenColor.PC_Red, PenColor.PC_Gray);
			}
			this.AddLengthDim(xyz7 + xyz2 + xyz3 / 2.0, xyz7 + xyz2 + xyz3 / 2.0 + hsDefine.m_dDistFromGround * basisY, XYZ.BasisX, hsDefine.m_dDistFromGround, "根部高度", PenColor.PC_Red, PenColor.PC_Gray);
			xyz6 += hsDefine.m_dDistFromGround * basisY + xyz3 / 2.0;
			xyz7 += hsDefine.m_dDistFromGround * basisY + xyz3 / 2.0;
			this.AddLine(xyz4 - xyz3 / 2.0, xyz6, this.m_colorPen, dHigh2);
			this.AddLine(xyz5 - xyz3 / 2.0, xyz7, this.m_colorPen, dHigh2);
			bool flag = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
			if (flag)
			{
				this.AddBaseLine(xyz6, -basisY, dHigh2, PenColor.PC_Gray);
			}
			bool flag2 = hsDefine.m_eLinkDevice2 > HSLinkDevice.kLinkDeviceNone;
			if (flag2)
			{
				this.AddBaseLine(xyz7, -basisY, dHigh2, PenColor.PC_Gray);
			}
			this.AddLengthDim(xyz6 + xyz2 / 2.0 + xyz3, xyz7 - xyz2 / 2.0 + xyz3, XYZ.BasisY, hsDefine.m_dNetWide, "净宽", PenColor.PC_Red, PenColor.PC_Gray);
			bool flag3 = hsDefine.m_eType == HSType.kDJ_DC3 || hsDefine.m_eType == HSType.kDJ_PX3;
			if (flag3)
			{
				XYZ xyz9 = xyz5 - xyz2 - hsDefine.m_dOffsetX * basisX;
				XYZ xyz10 = xyz7 - xyz2 - hsDefine.m_dOffsetX * basisX;
				this.AddLine(xyz9 - xyz3 / 2.0, xyz10, this.m_colorPen, dHigh2);
				this.AddLengthDim(xyz10 + xyz2 / 2.0 - 2.0 * xyz3, xyz7 - xyz2 / 2.0 - 2.0 * xyz3, XYZ.BasisY, hsDefine.m_dOffsetX, "中杆净宽", PenColor.PC_Red, PenColor.PC_Gray);
				bool flag4 = hsDefine.m_eLinkDevice3 > HSLinkDevice.kLinkDeviceNone;
				if (flag4)
				{
					this.AddBaseLine(xyz10, -basisY, dHigh2, PenColor.PC_Gray);
				}
			}
			if (bIsPX)
			{
				XYZ xyz11 = xyz5 - hsDefine.m_dPXHigh * basisY - xyz3;
				XYZ xyz12 = xyz11 - hsDefine.m_dPXWide * basisX - xyz2;
				XYZ pt = xyz5 - hsDefine.m_dPXWide * basisX - xyz2;
				this.AddLine(xyz11, xyz12, this.m_colorPen, dHigh2);
				this.AddLine(xyz12 - xyz3 / 2.0, pt, this.m_colorPen, dHigh2);
				this.AddLine(xyz11 - xyz3 / 2.0, xyz5, this.m_colorPen, dHigh2);
				this.AddLengthDim(xyz11 - xyz2 / 2.0 - xyz3, xyz12 + xyz2 / 2.0 - xyz3, -XYZ.BasisY, hsDefine.m_dPXWide, "偏心净宽", PenColor.PC_Red, PenColor.PC_Gray);
				this.AddLengthDim(xyz11 + xyz2 + xyz3 / 2.0, xyz5 + xyz2 - xyz3 / 2.0, XYZ.BasisX, hsDefine.m_dPXHigh, "偏心净高", PenColor.PC_Red, PenColor.PC_Gray);
			}
		}

		private void DrawSectionDJPX3(HSDefineInfo hsDefine)
		{
			this.DrawSectionDJDC3(hsDefine, true);
		}

		private void DrawSectionDJPX(HSDefineInfo hsDefine)
		{
			this.DrawSectionDJDC(hsDefine, true);
		}

		private void DrawSectionDJDZ(HSDefineInfo hsDefine)
		{
			XYZ xyz = new XYZ(100000.0, 100000.0, 0.0);
			xyz = this.m_ptBase;
			XYZ basisX = XYZ.BasisX;
			XYZ basisY = XYZ.BasisY;
			double dHigh = hsDefine.m_matHor.m_dHigh;
			double dHigh2 = hsDefine.m_matVer.m_dHigh;
			double num = hsDefine.m_dNetWide / 2.0;
			double num2 = num + dHigh2 / 2.0;
			XYZ xyz2 = basisX * dHigh2;
			XYZ xyz3 = basisY * dHigh;
			XYZ xyz4 = xyz - basisX * num2 - xyz3 / 2.0;
			XYZ xyz5 = xyz + basisX * num2 - xyz3 / 2.0;
			XYZ xyz6 = xyz4;
			XYZ xyz7 = xyz5;
			this.AddLine(xyz6 + basisX * dHigh2 / 2.0, xyz7, this.m_colorPen, dHigh);
			bool flag = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
			if (flag)
			{
				this.AddBaseLine(xyz6 + basisX * dHigh2 / 2.0, basisX, dHigh2, PenColor.PC_Gray);
			}
			for (int i = 1; i < hsDefine.m_nFloorNum; i++)
			{
				XYZ xyz8 = xyz7 + xyz3 / 2.0;
				double num3 = hsDefine.m_dNetHigh[i];
				xyz6 += num3 * basisY + xyz3;
				xyz7 += num3 * basisY + xyz3;
				this.AddLine(xyz6 + basisX * dHigh2 / 2.0, xyz7, this.m_colorPen, dHigh);
				this.AddLengthDim(xyz8 + xyz2, xyz7 + xyz2 - xyz3 / 2.0, XYZ.BasisX, num3, "净高" + i.ToString(), PenColor.PC_Red, PenColor.PC_Gray);
				bool flag2 = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
				if (flag2)
				{
					this.AddBaseLine(xyz6 + basisX * dHigh2 / 2.0, basisX, dHigh2, PenColor.PC_Gray);
				}
			}
			this.AddLengthDim(xyz7 + xyz2 + xyz3 / 2.0, xyz7 + xyz2 + xyz3 / 2.0 + hsDefine.m_dDistFromGround * basisY, XYZ.BasisX, hsDefine.m_dDistFromGround, "根部高度", PenColor.PC_Red, PenColor.PC_Gray);
			xyz6 += hsDefine.m_dDistFromGround * basisY + xyz3 / 2.0;
			xyz7 += hsDefine.m_dDistFromGround * basisY + xyz3 / 2.0;
			this.AddLine(xyz5 - xyz3 / 2.0, xyz7, this.m_colorPen, dHigh2);
			bool flag3 = hsDefine.m_eLinkDevice2 > HSLinkDevice.kLinkDeviceNone;
			if (flag3)
			{
				this.AddBaseLine(xyz7, -basisY, dHigh2, PenColor.PC_Gray);
			}
			this.AddLengthDim(xyz6 + xyz2 / 2.0 + xyz3, xyz7 - xyz2 / 2.0 + xyz3, XYZ.BasisY, hsDefine.m_dNetWide, "净宽", PenColor.PC_Red, PenColor.PC_Gray);
		}

		private void DrawSectionDJSL(HSDefineInfo hsDefine)
		{
			XYZ xyz = new XYZ(100000.0, 100000.0, 0.0);
			xyz = this.m_ptBase;
			XYZ basisX = XYZ.BasisX;
			XYZ basisY = XYZ.BasisY;
			double dHigh = hsDefine.m_matHor.m_dHigh;
			double dHigh2 = hsDefine.m_matVer.m_dHigh;
			double num = hsDefine.m_dNetWide / 2.0;
			double num2 = num + dHigh2 / 2.0;
			XYZ xyz2 = basisX * dHigh2;
			XYZ xyz3 = basisY * dHigh;
			XYZ xyz4 = xyz - basisX * num2 - xyz3 / 2.0;
			XYZ xyz5 = xyz + basisX * num2 - xyz3 / 2.0;
			XYZ xyz6 = xyz4;
			XYZ xyz7 = xyz5;
			this.AddLine(xyz6, xyz7, this.m_colorPen, dHigh);
			double num3 = hsDefine.m_dNetHigh[0];
			xyz6 += num3 * basisY + xyz3 / 2.0;
			xyz7 += num3 * basisY + xyz3 / 2.0;
			this.AddLine(xyz4 - xyz3 / 2.0, xyz6, this.m_colorPen, dHigh2);
			this.AddLine(xyz5 - xyz3 / 2.0, xyz7, this.m_colorPen, dHigh2);
			this.AddLengthDim(xyz5 + xyz3 / 2.0, xyz7, XYZ.BasisX, num3, "高", PenColor.PC_Red, PenColor.PC_Gray);
			bool flag = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
			if (flag)
			{
				this.AddBaseLine(xyz6, -basisY, dHigh2, PenColor.PC_Gray);
			}
			bool flag2 = hsDefine.m_eLinkDevice2 > HSLinkDevice.kLinkDeviceNone;
			if (flag2)
			{
				this.AddBaseLine(xyz7, -basisY, dHigh2, PenColor.PC_Gray);
			}
			this.AddLengthDim(xyz6 + xyz2 / 2.0 + 2.0 * xyz3, xyz7 - xyz2 / 2.0 + 2.0 * xyz3, XYZ.BasisY, hsDefine.m_dNetWide, "净宽", PenColor.PC_Red, PenColor.PC_Gray);
			XYZ xyz8 = basisX * hsDefine.m_dPXWide;
			this.AddLine(xyz5 + xyz3 / 2.0 - xyz2 - xyz8, xyz7 - xyz8 - xyz2, this.m_colorPen, dHigh2);
			bool flag3 = hsDefine.m_eLinkDevice3 > HSLinkDevice.kLinkDeviceNone;
			if (flag3)
			{
				this.AddBaseLine(xyz7 - xyz8 - xyz2, -basisY, dHigh2, PenColor.PC_Gray);
			}
			this.AddLengthDim(xyz7 - xyz2 / 2.0, xyz7 - xyz2 / 2.0 - xyz8, XYZ.BasisY, hsDefine.m_dPXWide, "偏心净宽", PenColor.PC_Red, PenColor.PC_Gray);
		}

		private void DrawSectionDJGJ(HSDefineInfo hsDefine)
		{
			XYZ xyz = new XYZ(100000.0, 100000.0, 0.0);
			xyz = this.m_ptBase;
			this.AddCircle(xyz, 10.0, PenColor.PC_Blue, 1.0);
			double num = 0.0;
			double dOffsetX = hsDefine.m_dOffsetX;
			double dOffsetY = hsDefine.m_dOffsetY;
			XYZ basisX = XYZ.BasisX;
			XYZ basisY = XYZ.BasisY;
			double dHigh = hsDefine.m_matHor.m_dHigh;
			double num2 = hsDefine.m_dNetWide / 2.0;
			double num3 = num2;
			XYZ xyz2 = basisY * dHigh;
			XYZ xyz3 = basisX * dOffsetX;
			XYZ xyz4 = basisY * dOffsetY;
			XYZ xyz5 = xyz - basisX * num3;
			XYZ xyz6 = xyz + basisX * num3;
			XYZ xyz7 = xyz5;
			XYZ xyz8 = xyz6;
			double num4 = hsDefine.m_dNetHigh[0];
			xyz7 += (num4 + num) * basisY;
			xyz8 += (num4 + num) * basisY;
			this.AddLine(xyz5 - xyz3 - xyz2 / 2.0, xyz6 + xyz3 - xyz2 / 2.0, this.m_colorPen, dHigh);
			double num5 = 0.0;
			this.AddLine(xyz5 - xyz4, xyz7, this.m_colorPen, num5);
			this.AddLine(xyz6 - xyz4, xyz8, this.m_colorPen, num5);
			bool flag = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
			if (flag)
			{
				this.AddBaseLine(xyz7, -basisY, num5, PenColor.PC_Gray);
			}
			bool flag2 = hsDefine.m_eLinkDevice2 > HSLinkDevice.kLinkDeviceNone;
			if (flag2)
			{
				this.AddBaseLine(xyz8, -basisY, num5, PenColor.PC_Gray);
			}
			this.AddLengthDim(xyz6 - xyz4 + xyz3, xyz8 + xyz3, XYZ.BasisX, num4, "高", PenColor.PC_Red, PenColor.PC_Gray);
			this.AddLengthDim(xyz6 + xyz3, xyz6 - xyz4 + xyz3, XYZ.BasisX, hsDefine.m_dOffsetY, "竖杆增加", PenColor.PC_Red, PenColor.PC_Gray);
			this.AddLengthDim(xyz7 - xyz2, xyz8 - xyz2, -XYZ.BasisY, hsDefine.m_dNetWide, "净宽", PenColor.PC_Red, PenColor.PC_Gray);
			this.AddLengthDim(xyz5 + xyz2, xyz5 - xyz3 + xyz2, XYZ.BasisY, dOffsetX, "横担增加", PenColor.PC_Red, PenColor.PC_Gray);
		}

		private void DrawSectionDJSG(HSDefineInfo hsDefine)
		{
			XYZ xyz = new XYZ(100000.0, 100000.0, 0.0);
			xyz = this.m_ptBase;
			this.AddCircle(xyz, 10.0, PenColor.PC_Blue, 1.0);
			this.AddText(xyz.X - 100.0, xyz.Y - 100.0, " ", false, PenColor.PC_Red, 50.0, TextNoteInfo.AlignHType.AHT_Center, TextNoteInfo.AlignVType.AVT_Bottom);
			double num = 0.0;
			XYZ basisX = XYZ.BasisX;
			XYZ basisY = XYZ.BasisY;
			double dHigh = hsDefine.m_matHor.m_dHigh;
			double num2 = hsDefine.m_dNetWide / 2.0;
			double num3 = num2;
			double dPXWide = hsDefine.m_dPXWide;
			XYZ xyz2 = basisY * dHigh;
			XYZ xyz3 = basisX * hsDefine.m_dOffsetX;
			XYZ xyz4 = basisY * hsDefine.m_dOffsetY;
			XYZ xyz5 = xyz - basisX * num3 - xyz2 / 2.0;
			XYZ xyz6 = xyz + basisX * num3 - xyz2 / 2.0;
			XYZ xyz7 = xyz5;
			XYZ xyz8 = xyz6;
			double num4 = hsDefine.m_dNetHigh[0];
			xyz7 += (num4 + num) * basisY;
			xyz8 += (num4 + num) * basisY;
			this.AddLine(xyz5 - xyz3, xyz6 + xyz3, this.m_colorPen, dHigh);
			double num5 = 0.0;
			XYZ xyz9 = basisX * dPXWide;
			this.AddLine(xyz5 - xyz4, xyz7, this.m_colorPen, num5);
			this.AddLine(xyz6 - xyz4, xyz8, this.m_colorPen, num5);
			this.AddLine(xyz6 - xyz4 - xyz9, xyz8 - xyz9, this.m_colorPen, num5);
			this.AddLengthDim(xyz6 - xyz4 + xyz3, xyz8 + xyz3, XYZ.BasisX, num4, "高", PenColor.PC_Red, PenColor.PC_Gray);
			bool flag = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
			if (flag)
			{
				this.AddBaseLine(xyz7, -basisY, num5, PenColor.PC_Gray);
			}
			bool flag2 = hsDefine.m_eLinkDevice2 > HSLinkDevice.kLinkDeviceNone;
			if (flag2)
			{
				this.AddBaseLine(xyz8, -basisY, num5, PenColor.PC_Gray);
			}
			bool flag3 = hsDefine.m_eLinkDevice3 > HSLinkDevice.kLinkDeviceNone;
			if (flag3)
			{
				this.AddBaseLine(xyz8 - xyz9, -basisY, num5, PenColor.PC_Gray);
			}
			this.AddLengthDim(xyz7 + xyz2, xyz8 + xyz2, XYZ.BasisY, hsDefine.m_dNetWide, "净宽", PenColor.PC_Red, PenColor.PC_Gray);
			this.AddLengthDim(xyz6 + xyz3 + xyz2 / 2.0, xyz6 - xyz4 + xyz3, XYZ.BasisX, hsDefine.m_dOffsetY, "竖杆增加", PenColor.PC_Red, PenColor.PC_Gray);
			this.AddLengthDim(xyz5 + xyz2, xyz5 - xyz3 + xyz2, XYZ.BasisY, hsDefine.m_dOffsetX, "横担增加", PenColor.PC_Red, PenColor.PC_Gray);
			this.AddLengthDim(xyz6 + xyz2, xyz6 + xyz2 - xyz9, XYZ.BasisY, hsDefine.m_dPXWide, "偏心净宽", PenColor.PC_Red, PenColor.PC_Gray);
		}

		private void DrawSectionDJDB(HSDefineInfo hsDefine)
		{
			XYZ xyz = new XYZ(100000.0, 100000.0, 0.0);
			xyz = this.m_ptBase;
			XYZ basisX = XYZ.BasisX;
			XYZ basisY = XYZ.BasisY;
			double num = hsDefine.m_dNetHigh[0];
			XYZ xyz2 = xyz + num * basisY;
			this.AddLine(xyz, xyz2, this.m_colorPen, hsDefine.m_matVer.m_dHigh);
			bool flag = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
			if (flag)
			{
				this.AddBaseLine(xyz2, -basisY, hsDefine.m_matVer.m_dHigh, PenColor.PC_Gray);
			}
			XYZ xyz3 = basisX * 100.0;
			this.AddLengthDim(xyz + xyz3, xyz2 + xyz3, XYZ.BasisX, num, "高", PenColor.PC_Red, PenColor.PC_Gray);
		}

		private void DrawSectionDJDG(HSDefineInfo hsDefine)
		{
			XYZ xyz = new XYZ(100000.0, 100000.0, 0.0);
			xyz = this.m_ptBase;
			this.AddCircle(xyz, 3.0, PenColor.PC_Blue, 1.0);
			XYZ basisX = XYZ.BasisX;
			XYZ basisY = XYZ.BasisY;
			double dLoopDiameter = hsDefine.m_dLoopDiameter;
			double dGapHor = hsDefine.m_dGapHor;
			double dLoopThick = hsDefine.m_dLoopThick;
			XYZ xyz2 = xyz + (hsDefine.m_dNetHigh[0] + dLoopDiameter / 2.0 + dGapHor + dLoopThick) * basisY;
			XYZ pt = xyz + basisY * (dLoopDiameter / 2.0 + dGapHor + dLoopThick);
			this.AddLine(pt, xyz2, this.m_colorPen, 0.0);
			this.AddLengthDim(pt, xyz2, XYZ.BasisX, hsDefine.m_dNetHigh[0], "高", PenColor.PC_Red, PenColor.PC_Gray);
			bool flag = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
			if (flag)
			{
				this.AddBaseLine(xyz2, -basisY, hsDefine.m_matVer.m_dHigh, PenColor.PC_Gray);
			}
			this.AddCircle(xyz, dLoopDiameter / 2.0 + dGapHor + dLoopThick / 2.0, this.m_colorPen, dLoopThick);
			XYZ xyz3 = basisX * (dLoopDiameter / 2.0);
			this.AddLengthDim(xyz - xyz3 - basisY * (dLoopDiameter / 2.0), xyz + xyz3 - basisY * (dLoopDiameter / 2.0), -XYZ.BasisY, hsDefine.m_dLoopDiameter, "管径", PenColor.PC_Red, PenColor.PC_Gray);
		}

		private void DrawSectionZJPX(HSDefineInfo hsDefine)
		{
			this.DrawSectionZJDC(hsDefine, true);
		}

		private void DrawSectionZJDC(HSDefineInfo hsDefine, bool bIsPX = false)
		{
			XYZ xyz = new XYZ(0.0, 0.0, 0.0);
			xyz = this.m_ptBase;
			XYZ basisX = XYZ.BasisX;
			XYZ xyz2 = -XYZ.BasisY;
			double dHigh = hsDefine.m_matHor.m_dHigh;
			double dHigh2 = hsDefine.m_matVer.m_dHigh;
			double num = hsDefine.m_dNetWide / 2.0;
			double num2 = num + dHigh2 / 2.0;
			XYZ xyz3 = basisX * dHigh2;
			XYZ xyz4 = xyz2 * dHigh;
			XYZ xyz5 = xyz - basisX * num2 + xyz4 / 2.0;
			XYZ xyz6 = xyz + basisX * num2 + xyz4 / 2.0;
			XYZ xyz7 = xyz5;
			XYZ xyz8 = xyz6;
			this.AddLine(xyz7, xyz8, this.m_colorPen, dHigh);
			for (int i = 1; i < hsDefine.m_nFloorNum; i++)
			{
				XYZ xyz9 = xyz8 + xyz4 / 2.0;
				double num3 = hsDefine.m_dNetHigh[i];
				xyz7 += num3 * xyz2 + xyz4;
				xyz8 += num3 * xyz2 + xyz4;
				this.AddLine(xyz7, xyz8, this.m_colorPen, dHigh);
				this.AddLengthDim(xyz9 + xyz3, xyz8 + xyz3 - xyz4 / 2.0, XYZ.BasisX, num3, "偏心净高" + i.ToString(), PenColor.PC_Red, PenColor.PC_Gray);
			}
			this.AddLengthDim(xyz8 + xyz3 + xyz4 / 2.0, xyz8 + xyz3 + xyz4 / 2.0 + hsDefine.m_dDistFromGround * xyz2, XYZ.BasisX, hsDefine.m_dDistFromGround, "根部高度", PenColor.PC_Red, PenColor.PC_Gray);
			xyz7 += hsDefine.m_dDistFromGround * xyz2 + xyz4 / 2.0;
			xyz8 += hsDefine.m_dDistFromGround * xyz2 + xyz4 / 2.0;
			this.AddLine(xyz5 - xyz4 / 2.0, xyz7, this.m_colorPen, dHigh2);
			this.AddLine(xyz6 - xyz4 / 2.0, xyz8, this.m_colorPen, dHigh2);
			bool flag = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
			if (flag)
			{
				this.AddBaseLine(xyz7, -xyz2, dHigh2, PenColor.PC_Gray);
			}
			bool flag2 = hsDefine.m_eLinkDevice2 > HSLinkDevice.kLinkDeviceNone;
			if (flag2)
			{
				this.AddBaseLine(xyz8, -xyz2, dHigh2, PenColor.PC_Gray);
			}
			this.AddLengthDim(xyz7 + xyz3 / 2.0 + xyz4 * 1.0, xyz8 - xyz3 / 2.0 + xyz4 * 1.0, xyz2, hsDefine.m_dNetWide, "净宽", PenColor.PC_Red, PenColor.PC_Gray);
			if (bIsPX)
			{
				XYZ xyz10 = -xyz2 * hsDefine.m_dPXHigh - xyz4;
				XYZ xyz11 = basisX * hsDefine.m_dPXWide + xyz3;
				this.AddLine(xyz6, xyz6 + xyz10 - xyz4 / 2.0, this.m_colorPen, dHigh2);
				this.AddLine(xyz6 - xyz11, xyz6 + xyz10 - xyz11 - xyz4 / 2.0, this.m_colorPen, dHigh2);
				this.AddLine(xyz6 + xyz10 - xyz11, xyz6 + xyz10, this.m_colorPen, dHigh2);
				this.AddLengthDim(xyz6 + xyz3 - xyz4 / 2.0, xyz6 + xyz3 + xyz4 / 2.0 + xyz10, XYZ.BasisX, hsDefine.m_dPXHigh, "偏心净高", PenColor.PC_Red, PenColor.PC_Gray);
				this.AddLengthDim(xyz6 + xyz10 - xyz11 + xyz3 / 2.0, xyz6 + xyz10 - xyz3 / 2.0, XYZ.BasisY, hsDefine.m_dPXWide, "偏心净宽", PenColor.PC_Red, PenColor.PC_Gray);
			}
		}

		private void DrawSectionZJDZ(HSDefineInfo hsDefine)
		{
			XYZ xyz = new XYZ(0.0, 0.0, 0.0);
			xyz = this.m_ptBase;
			XYZ basisX = XYZ.BasisX;
			XYZ xyz2 = -XYZ.BasisY;
			double dHigh = hsDefine.m_matHor.m_dHigh;
			double dHigh2 = hsDefine.m_matVer.m_dHigh;
			double num = hsDefine.m_dNetWide / 2.0;
			double num2 = num + dHigh2 / 2.0;
			XYZ xyz3 = basisX * dHigh2;
			XYZ xyz4 = xyz2 * dHigh;
			XYZ xyz5 = xyz - basisX * num2 + xyz4 / 2.0;
			XYZ xyz6 = xyz + basisX * num2 + xyz4 / 2.0;
			XYZ xyz7 = xyz5;
			XYZ xyz8 = xyz6;
			this.AddLine(xyz7 + basisX * dHigh2 / 2.0, xyz8, this.m_colorPen, dHigh);
			bool flag = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
			if (flag)
			{
				this.AddBaseLine(xyz7 + basisX * dHigh2 / 2.0, basisX, dHigh2, PenColor.PC_Gray);
			}
			for (int i = 1; i < hsDefine.m_nFloorNum; i++)
			{
				XYZ xyz9 = xyz8 + xyz4 / 2.0;
				double num3 = hsDefine.m_dNetHigh[i];
				xyz7 += num3 * xyz2 + xyz4;
				xyz8 += num3 * xyz2 + xyz4;
				this.AddLine(xyz7 + basisX * dHigh2 / 2.0, xyz8, this.m_colorPen, dHigh);
				this.AddLengthDim(xyz9 + xyz3, xyz8 + xyz3 - xyz4 / 2.0, XYZ.BasisX, num3, "偏心净高" + i.ToString(), PenColor.PC_Red, PenColor.PC_Gray);
				bool flag2 = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
				if (flag2)
				{
					this.AddBaseLine(xyz7 + basisX * dHigh2 / 2.0, basisX, dHigh2, PenColor.PC_Gray);
				}
			}
			this.AddLengthDim(xyz8 + xyz3 + xyz4 / 2.0, xyz8 + xyz3 + xyz4 / 2.0 + hsDefine.m_dDistFromGround * xyz2, XYZ.BasisX, hsDefine.m_dDistFromGround, "根部高度", PenColor.PC_Red, PenColor.PC_Gray);
			xyz7 += hsDefine.m_dDistFromGround * xyz2 + xyz4 / 2.0;
			xyz8 += hsDefine.m_dDistFromGround * xyz2 + xyz4 / 2.0;
			this.AddLine(xyz6 - xyz4 / 2.0, xyz8, this.m_colorPen, dHigh2);
			bool flag3 = hsDefine.m_eLinkDevice2 > HSLinkDevice.kLinkDeviceNone;
			if (flag3)
			{
				this.AddBaseLine(xyz8, -xyz2, dHigh2, PenColor.PC_Gray);
			}
			this.AddLengthDim(xyz7 + xyz3 / 2.0 + xyz4 * 1.0, xyz8 - xyz3 / 2.0 + xyz4 * 1.0, xyz2, hsDefine.m_dNetWide, "净宽", PenColor.PC_Red, PenColor.PC_Gray);
		}

		private void DrawSectionZJSJ(HSDefineInfo hsDefine)
		{
			XYZ xyz = new XYZ(0.0, 1000000.0, 0.0);
			xyz = this.m_ptBase;
			XYZ basisX = XYZ.BasisX;
			XYZ basisY = XYZ.BasisY;
			double dHigh = hsDefine.m_matHor.m_dHigh;
			double dHigh2 = hsDefine.m_matVer.m_dHigh;
			double dHigh3 = hsDefine.m_matLean.m_dHigh;
			double dNetWide = hsDefine.m_dNetWide;
			double num = hsDefine.m_dNetHigh[0];
			double dOffsetX = hsDefine.m_dOffsetX;
			double dOffsetY = hsDefine.m_dOffsetY;
			xyz = Utils.SetPtX(xyz, xyz.X - dNetWide / 2.0);
			XYZ xyz2 = basisX * dHigh2;
			XYZ xyz3 = basisY * dHigh;
			XYZ xyz4 = xyz - xyz3 / 2.0;
			XYZ xyz5 = xyz + basisX * dNetWide - xyz3 / 2.0 + xyz2;
			XYZ xyz6 = xyz4 + basisX * dHigh2 / 2.0 + basisY * dHigh / 2.0;
			XYZ xyz7 = xyz6;
			xyz7 -= basisY * num;
			this.AddLine(xyz4, xyz5, this.m_colorPen, dHigh);
			this.AddLine(xyz6, xyz7, this.m_colorPen, dHigh2);
			XYZ xyz8 = xyz2 * 2.0;
			XYZ xyz9 = xyz3 * 2.0;
			this.AddLengthDim(xyz4 + xyz9 + xyz8 / 2.0, xyz5 + xyz9, basisY, dNetWide, "宽", PenColor.PC_Red, PenColor.PC_Gray);
			this.AddLengthDim(xyz6, xyz7, -basisX, num, "高", PenColor.PC_Red, PenColor.PC_Gray);
			XYZ xyz10 = xyz4 + basisX * dOffsetX;
			XYZ xyz11 = xyz6 - basisY * dOffsetY;
			this.AddLine(xyz10, xyz11, this.m_colorPen, dHigh3);
			this.AddLengthDim(xyz10 + xyz3 * 2.0 + xyz9 + xyz2, xyz4 + xyz3 * 2.0 + xyz9 + xyz8 / 2.0, basisY, dOffsetX, "斜撑宽", PenColor.PC_Red, PenColor.PC_Gray);
			this.AddLengthDim(xyz11 - xyz2 / 2.0 - xyz8, xyz6 - xyz2 / 2.0 - xyz8, -basisX, dOffsetY, "斜撑高", PenColor.PC_Red, PenColor.PC_Gray);
		}

		private void DrawSectionZJXB(HSDefineInfo hsDefine)
		{
			XYZ xyz = new XYZ(100000.0, 100000.0, 0.0);
			xyz = this.m_ptBase;
			XYZ basisX = XYZ.BasisX;
			XYZ basisY = XYZ.BasisY;
			double dHigh = hsDefine.m_matHor.m_dHigh;
			double dNetWide = hsDefine.m_dNetWide;
			XYZ xyz2 = basisY * dHigh;
			xyz = Utils.SetPtX(xyz, xyz.X - dNetWide / 2.0);
			XYZ xyz3 = xyz - xyz2 / 2.0;
			XYZ xyz4 = xyz3 + basisX * dNetWide;
			this.AddLine(xyz3, xyz4, this.m_colorPen, dHigh);
			this.AddLengthDim(xyz3 + xyz2 * 2.0, xyz4 + xyz2 * 2.0, basisY, dNetWide, "宽", PenColor.PC_Red, PenColor.PC_Gray);
			bool flag = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
			if (flag)
			{
				this.AddBaseLine(xyz3, basisX, dHigh, PenColor.PC_Gray);
			}
		}

		private void DrawSectionZJCB(HSDefineInfo hsDefine)
		{
			XYZ xyz = new XYZ(100000.0, 100000.0, 0.0);
			xyz = this.m_ptBase;
			double dLoopDiameter = hsDefine.m_dLoopDiameter;
			double dGapHor = hsDefine.m_dGapHor;
			double dLoopThick = hsDefine.m_dLoopThick;
			XYZ basisX = XYZ.BasisX;
			XYZ basisY = XYZ.BasisY;
			double dHigh = hsDefine.m_matHor.m_dHigh;
			double dNetWide = hsDefine.m_dNetWide;
			XYZ xyz2 = basisY * dHigh;
			xyz = Utils.SetPtX(xyz, xyz.X - (dNetWide + dLoopDiameter / 2.0 + dGapHor + dLoopThick));
			XYZ xyz3 = xyz;
			XYZ xyz4 = xyz3 + basisX * dNetWide;
			this.AddLine(xyz3, xyz4, this.m_colorPen, dHigh);
			XYZ xyz5 = xyz4 + basisX * (dGapHor + dLoopThick + dLoopDiameter / 2.0);
			this.AddCircle(xyz5, dLoopDiameter / 2.0 + dGapHor + dLoopThick / 2.0, this.m_colorPen, dLoopThick);
			XYZ xyz6 = basisX * (dLoopDiameter / 2.0 + dGapHor);
			this.AddLengthDim(xyz5 - xyz6 - basisY * (dLoopDiameter / 2.0), xyz5 + xyz6 - basisY * (dLoopDiameter / 2.0), -XYZ.BasisY, hsDefine.m_dLoopDiameter, "管径", PenColor.PC_Red, PenColor.PC_Gray);
			this.AddLengthDim(xyz3 + xyz2 * 2.0, xyz4 + xyz2 * 2.0, basisY, dNetWide, "宽", PenColor.PC_Red, PenColor.PC_Gray);
			bool flag = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
			if (flag)
			{
				this.AddBaseLine(xyz3, basisX, dHigh, PenColor.PC_Gray);
			}
		}

		private void DrawSectionDJZJ(HSDefineInfo hsDefine)
		{
			XYZ xyz = new XYZ(100000.0, 100000.0, 0.0);
			xyz = this.m_ptBase;
			XYZ basisX = XYZ.BasisX;
			XYZ basisY = XYZ.BasisY;
			double dHigh = hsDefine.m_matHor.m_dHigh;
			double dHigh2 = hsDefine.m_matVer.m_dHigh;
			double num = hsDefine.m_dNetWide / 2.0;
			double num2 = num + dHigh2 / 2.0;
			XYZ xyz2 = basisX * dHigh2;
			XYZ xyz3 = basisY * dHigh;
			XYZ xyz4 = xyz - basisX * num2 - xyz3 / 2.0;
			XYZ xyz5 = xyz + basisX * num2 - xyz3 / 2.0;
			XYZ xyz6 = xyz4;
			XYZ xyz7 = xyz5;
			this.AddLine(xyz6, xyz7, this.m_colorPen, dHigh);
			double num3 = hsDefine.m_dNetHigh[0];
			xyz6 += num3 * basisY + xyz3 / 2.0;
			xyz7 += num3 * basisY + xyz3 / 2.0;
			this.AddLengthDim(xyz5 + xyz3 / 2.0, xyz7, XYZ.BasisX, num3, "高", PenColor.PC_Red, PenColor.PC_Gray);
			this.AddLine(xyz5 - xyz3 / 2.0, xyz7, this.m_colorPen, dHigh2);
			bool flag = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
			if (flag)
			{
				this.AddBaseLine(xyz4, basisX, dHigh2, PenColor.PC_Gray);
			}
			bool flag2 = hsDefine.m_eLinkDevice2 > HSLinkDevice.kLinkDeviceNone;
			if (flag2)
			{
				this.AddBaseLine(xyz7, -basisY, dHigh2, PenColor.PC_Gray);
			}
			this.AddLengthDim(xyz6 + xyz2 / 2.0 + xyz3, xyz7 - xyz2 / 2.0 + xyz3, XYZ.BasisY, hsDefine.m_dNetWide, "净宽", PenColor.PC_Red, PenColor.PC_Gray);
		}

		private void DrawSectionDJYC(HSDefineInfo hsDefine)
		{
			XYZ xyz = new XYZ(100000.0, 100000.0, 0.0);
			xyz = this.m_ptBase;
			XYZ basisX = XYZ.BasisX;
			XYZ basisY = XYZ.BasisY;
			double dHigh = hsDefine.m_matHor.m_dHigh;
			double dHigh2 = hsDefine.m_matVer.m_dHigh;
			double num = hsDefine.m_dNetWide / 2.0;
			double num2 = num + dHigh2 / 2.0;
			XYZ xyz2 = basisX * dHigh2;
			XYZ xyz3 = basisY * dHigh;
			XYZ xyz4 = xyz - basisX * num2 - xyz3 / 2.0;
			XYZ xyz5 = xyz + basisX * num2 - xyz3 / 2.0;
			XYZ xyz6 = xyz4;
			XYZ xyz7 = xyz5;
			XYZ xyz8 = basisX * hsDefine.m_dOffsetX;
			XYZ xyz9 = basisY * hsDefine.m_dOffsetY;
			this.AddLine(xyz6 - xyz8, xyz7 + xyz8, this.m_colorPen, dHigh);
			for (int i = 1; i < hsDefine.m_nFloorNum; i++)
			{
				XYZ xyz10 = xyz7 + xyz3 / 2.0;
				double num3 = hsDefine.m_dNetHigh[i];
				xyz6 += num3 * basisY + xyz3;
				xyz7 += num3 * basisY + xyz3;
				this.AddLine(xyz6 - xyz8, xyz7 + xyz8, this.m_colorPen, dHigh);
				this.AddLengthDim(xyz10 + xyz2 + xyz8, xyz7 + xyz2 - xyz3 / 2.0 + xyz8, XYZ.BasisX, num3, "净高" + i.ToString(), PenColor.PC_Red, PenColor.PC_Gray);
			}
			this.AddLengthDim(xyz7 + xyz2 + xyz3 / 2.0 + xyz8, xyz7 + xyz2 + xyz3 / 2.0 + xyz8 + hsDefine.m_dDistFromGround * basisY, XYZ.BasisX, hsDefine.m_dDistFromGround, "根部高度", PenColor.PC_Red, PenColor.PC_Gray);
			this.AddLengthDim(xyz5 + xyz2 - xyz3 + xyz8, xyz5 + xyz2 - xyz3 / 2.0 + xyz8 - hsDefine.m_dOffsetY * basisY, XYZ.BasisX, hsDefine.m_dOffsetY, "竖杆增加", PenColor.PC_Red, PenColor.PC_Gray);
			this.AddLengthDim(xyz4 - xyz2 / 2.0 - xyz3 - xyz9, xyz4 - xyz2 / 2.0 - xyz3 - xyz8 - xyz9, -XYZ.BasisY, hsDefine.m_dOffsetX, "横担增加", PenColor.PC_Red, PenColor.PC_Gray);
			xyz6 += hsDefine.m_dDistFromGround * basisY + xyz3 / 2.0;
			xyz7 += hsDefine.m_dDistFromGround * basisY + xyz3 / 2.0;
			this.AddLine(xyz4 - xyz3 / 2.0 - basisY * hsDefine.m_dOffsetY, xyz6, this.m_colorPen, dHigh2);
			this.AddLine(xyz5 - xyz3 / 2.0 - basisY * hsDefine.m_dOffsetY, xyz7, this.m_colorPen, dHigh2);
			bool flag = hsDefine.m_eLinkDevice1 > HSLinkDevice.kLinkDeviceNone;
			if (flag)
			{
				this.AddBaseLine(xyz6, -basisY, dHigh2, PenColor.PC_Gray);
			}
			bool flag2 = hsDefine.m_eLinkDevice2 > HSLinkDevice.kLinkDeviceNone;
			if (flag2)
			{
				this.AddBaseLine(xyz7, -basisY, dHigh2, PenColor.PC_Gray);
			}
			this.AddLengthDim(xyz6 + xyz2 / 2.0 + xyz3, xyz7 - xyz2 / 2.0 + xyz3, XYZ.BasisY, hsDefine.m_dNetWide, "净宽", PenColor.PC_Red, PenColor.PC_Gray);
		}

		private void DrawSection()
		{
			this.m_lstViewCurves = new List<CurveInfo>();
			this.m_lstViewTexts = new List<TextNoteInfo>();
			this.DrawSection(this.m_selHSDefineInfo);
			this.pictureBox.TextNotes = this.m_lstViewTexts;
			this.pictureBox.Curves = this.m_lstViewCurves;
			base.Invalidate();
		}

		private void DlgHSDesign_Load(object sender, EventArgs e)
		{
			((ISupportInitialize)this.pictureBox).BeginInit();
			this.pictureBox.ZoomExtents();
		}

		private void RefreshPreview(Graphics g)
		{
			this.DrawSection();
		}

		private void DrawPipeSecSelect()
		{
			List<PipeSectionDef> selSecLst = this.m_secSelectInfo.GetSelSecLst();
			bool flag = selSecLst.Count < 1;
			if (!flag)
			{
				bool flag2 = this.m_selHSDefineInfo.m_eType == HSType.kDJ_DG || this.m_selHSDefineInfo.m_eType == HSType.kZJ_CB;
				if (flag2)
				{
					bool flag3 = selSecLst.Count >= 2;
					if (flag3)
					{
						return;
					}
				}
				PenColor colorCur = PenColor.PC_DarkCyan;
				PenColor colorCur2 = PenColor.PC_Gray;
				double dPenWide = 0.0;
				double num = selSecLst[0].m_dDistX;
				double num2 = num;
				double num3 = selSecLst[0].m_dElevation;
				double num4 = num3;
				foreach (PipeSectionDef pipeSectionDef in selSecLst)
				{
					XYZ xyz = new XYZ(pipeSectionDef.m_dDistX, pipeSectionDef.m_dElevation, 0.0);
					bool flag4 = xyz.X < num;
					if (flag4)
					{
						num = xyz.X;
					}
					bool flag5 = xyz.X > num2;
					if (flag5)
					{
						num2 = xyz.X;
					}
					bool flag6 = xyz.Y < num3;
					if (flag6)
					{
						num3 = xyz.Y;
					}
					bool flag7 = xyz.Y > num4;
					if (flag7)
					{
						num4 = xyz.Y;
					}
					double num5 = pipeSectionDef.High();
					switch (pipeSectionDef.m_eSecType)
					{
					case SectionType.kCircle:
						this.AddCircle(xyz, pipeSectionDef.m_dWide / 2.0, colorCur, dPenWide);
						break;
					case SectionType.kRect:
					{
						XYZ xyz2 = pipeSectionDef.m_dWide / 2.0 * XYZ.BasisX;
						XYZ xyz3 = pipeSectionDef.m_dHigh / 2.0 * XYZ.BasisY;
						XYZ pt = xyz + xyz2 + xyz3;
						XYZ pt2 = xyz - xyz2 + xyz3;
						XYZ pt3 = xyz - xyz2 - xyz3;
						XYZ pt4 = xyz + xyz2 - xyz3;
						this.AddLine(pt, pt2, colorCur, dPenWide);
						this.AddLine(pt3, pt2, colorCur, dPenWide);
						this.AddLine(pt3, pt4, colorCur, dPenWide);
						this.AddLine(pt, pt4, colorCur, dPenWide);
						break;
					}
					case SectionType.kOval:
						this.AddEllipse(pipeSectionDef.m_dDistX, pipeSectionDef.m_dElevation, pipeSectionDef.m_dWide / 2.0, pipeSectionDef.m_dHigh / 2.0, colorCur, dPenWide);
						break;
					default:
						continue;
					}
					XYZ xyz4 = XYZ.BasisY * (num5 / 2.0 + 5.0);
					double num6 = 30.0;
					this.AddText(xyz, pipeSectionDef.m_strFamilyName + "\n" + pipeSectionDef.SizeInfo(), false, colorCur2, num6, TextNoteInfo.AlignHType.AHT_Center, TextNoteInfo.AlignVType.AVT_Bottom);
					double num7 = pipeSectionDef.m_dElevation + num5 / 2.0;
					double num8 = pipeSectionDef.m_dElevation - num5 / 2.0;
					this.AddText(xyz + xyz4, "▼顶" + num7.ToString("f0"), false, colorCur2, num6, TextNoteInfo.AlignHType.AHT_Center, TextNoteInfo.AlignVType.AVT_Bottom);
					this.AddText(xyz - xyz4 - XYZ.BasisY * num6, "▲底" + num8.ToString("f0"), false, colorCur2, num6, TextNoteInfo.AlignHType.AHT_Center, TextNoteInfo.AlignVType.AVT_Bottom);
				}
			}
		}

		private void btnGetSection_Click(object sender, EventArgs e)
		{
			this.m_kDrawType = HSDrawType.eDrawTypeSelectSection;
			this.m_secSelectInfo.Clear();
			base.Close();
			base.DialogResult = DialogResult.OK;
		}

		private void btnApplyToSelect_Click(object sender, EventArgs e)
		{
			this.m_kDrawType = HSDrawType.eDrawTypeApplyToSelect;
			base.Close();
			base.DialogResult = DialogResult.OK;
		}

		private void btnDeleteSection_Click(object sender, EventArgs e)
		{
			this.m_secSelectInfo.ClearAll();
			this.DrawSection();
			this.pictureBox.ZoomExtents();
		}

		private void btnDrawSingle_Click(object sender, EventArgs e)
		{
			this.m_kDrawType = HSDrawType.eDrawTypeDrawSingle;
			base.Close();
			base.DialogResult = DialogResult.OK;
		}

		private void btnDrawByPipe_Click(object sender, EventArgs e)
		{
			this.m_kDrawType = HSDrawType.eDrawTypeDrawByPipe;
			base.Close();
			base.DialogResult = DialogResult.OK;
		}

		private void btnDrawByWall_Click(object sender, EventArgs e)
		{
			bool flag = this.m_secSelectInfo.m_listSecSel.Count == 0;
			if (flag)
			{
				Utils.MessageBox("请先选择管道进行剖面提取");
			}
			else
			{
				this.m_kDrawType = HSDrawType.eDrawTypeDrawByWall;
				base.Close();
				base.DialogResult = DialogResult.OK;
			}
		}

		private void btnDrawByCurve_Click(object sender, EventArgs e)
		{
			this.m_kDrawType = HSDrawType.eDrawTypeDrawByCurve;
			base.Close();
			base.DialogResult = DialogResult.OK;
		}

		private void btnClose_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
			base.Close();
		}

		private void btnDrawBySectionPipe_Click(object sender, EventArgs e)
		{
			List<PipeSectionDef> selSecLst = this.m_secSelectInfo.GetSelSecLst();
			bool flag = selSecLst.Count == 0;
			if (flag)
			{
				Utils.MessageBox("没有进行剖面提取，不能使用此功能");
			}
			else
			{
				this.m_kDrawType = HSDrawType.eDrawTypeDrawBySectionPipe;
				base.Close();
				base.DialogResult = DialogResult.OK;
			}
		}

		private void btnDrawBySectionLine_Click(object sender, EventArgs e)
		{
			this.m_kDrawType = HSDrawType.eDrawTypeDrawBySectionLine;
			this.GetPropDefine();
			base.Close();
			base.DialogResult = DialogResult.OK;
		}

		private void btnDrawByMultiPipes_Click(object sender, EventArgs e)
		{
			this.m_kDrawType = HSDrawType.eDrawTypeDrawBy2Pipe;
			base.Close();
			base.DialogResult = DialogResult.OK;
		}

		private void btnGetDefineFromDraw_Click(object sender, EventArgs e)
		{
			this.m_kDrawType = HSDrawType.eDrawTypeGetDefFromDraw;
			base.Close();
			base.DialogResult = DialogResult.OK;
		}

		public void SetPropDefine()
		{
			bool flag = this.m_selHSDefineInfo.m_strElevationName == "" && this.m_curLevel != null;
			if (flag)
			{
				this.m_selHSDefineInfo.m_strElevationName = this.m_curLevel.Name;
			}
			this.propertyGridHSDefine.PropertySort = PropertySort.Categorized;
			this.m_hsPropManage.SetHSDefine(ref this.m_selHSDefineInfo);
			this.propertyGridHSDefine.SelectedObject = this.m_hsPropManage;
		}

		public void GetPropDefine()
		{
			HSDefineInfo hsdefineInfo = new HSDefineInfo(this.m_selHSDefineInfo);
			bool value = this.m_hsPropManage.GetValue(ref hsdefineInfo);
			bool flag = !hsdefineInfo.IsDefineValid();
			if (flag)
			{
				this.SetPropDefine();
				Utils.MessageBox(hsdefineInfo.m_strErrorInfo);
			}
			else
			{
				this.m_selHSDefineInfo = hsdefineInfo;
				this.SetPropDefine();
			}
		}

		private void propertyGridHSDefine_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
		{
			bool bMirrored = this.m_selHSDefineInfo.m_bMirrored;
			int nFloorNum = this.m_selHSDefineInfo.m_nFloorNum;
			int num = (int)this.m_selHSDefineInfo.GetHighFromBase();
			int num2 = (int)this.m_selHSDefineInfo.m_dElevationOffset;
			this.GetPropDefine();
			bool bIncludeSelectSections = false;
			bool flag = this.m_selHSDefineInfo.m_bChangeOnlyBaseHigh && num != (int)this.m_selHSDefineInfo.GetHighFromBase();
			if (flag)
			{
				double highFromBase = this.m_selHSDefineInfo.GetHighFromBase();
				this.m_selHSDefineInfo.SetHighFromBase((double)num);
				this.m_selHSDefineInfo.ChangeHighFromBase(highFromBase);
				bIncludeSelectSections = false;
			}
			bool flag2 = this.m_selHSDefineInfo.m_bChangeOnlyBaseHigh && num2 != (int)this.m_selHSDefineInfo.m_dElevationOffset;
			if (flag2)
			{
				double dElevationOffset = this.m_selHSDefineInfo.m_dElevationOffset;
				double num3 = dElevationOffset - (double)num2;
				double num4 = (double)num + num3;
				bool flag3 = num4 > 0.0;
				if (flag3)
				{
					this.m_selHSDefineInfo.SetHighFromBase(num4);
				}
				bIncludeSelectSections = false;
			}
			bool flag4 = nFloorNum != this.m_selHSDefineInfo.m_nFloorNum || bMirrored != this.m_selHSDefineInfo.m_bMirrored;
			if (flag4)
			{
				bIncludeSelectSections = true;
			}
			this.AutoAdjustHSSectionSize(this.m_kDrawType, bIncludeSelectSections);
			this.SetPropDefine();
			this.DrawSection();
			this.pictureBox.ZoomExtents();
		}

		public static void CalLevelInfoByDef(ref HSDefineInfo selHSDefineInfo, Autodesk.Revit.DB.Document doc, bool bSelectPipesSection, HSDrawType drawType)
		{
			bool flag = bSelectPipesSection && drawType == HSDrawType.eDrawTypeDrawByPipe;
			if (!flag)
			{
				Level level = Utils.GetLevel(selHSDefineInfo.m_strElevationName, doc);
				bool flag2 = level == null;
				if (!flag2)
				{
					double num = Utils.feetToMM(level.Elevation);
					double num2 = selHSDefineInfo.m_dElevation;
					double num3 = num;
					double num4 = num;
					HSDraw.GetUpDownLevel(ref num3, ref num4, num2, doc);
					bool flag3 = selHSDefineInfo.m_eType == HSType.kZJ_DC || selHSDefineInfo.m_eType == HSType.kZJ_DZ || selHSDefineInfo.m_eType == HSType.kZJ_PX;
					if (flag3)
					{
						for (int i = 1; i < selHSDefineInfo.m_nFloorNum; i++)
						{
							num2 -= selHSDefineInfo.m_matHor.m_dHigh + selHSDefineInfo.m_dNetHigh[i];
						}
						num2 -= selHSDefineInfo.m_matHor.m_dHigh;
						HSDraw.GetUpDownLevel(ref num3, ref num4, num2, doc);
						bool flag4 = num < num2;
						if (flag4)
						{
							selHSDefineInfo.m_dDistFromGround = num2 - num;
						}
						else
						{
							bool flag5 = num4 < num2;
							if (flag5)
							{
								selHSDefineInfo.m_dDistFromGround = num2 - num4;
							}
						}
						bool flag6 = selHSDefineInfo.m_dDistFromGround < 10.0;
						if (flag6)
						{
							selHSDefineInfo.m_dDistFromGround = 10.0;
						}
						num2 -= selHSDefineInfo.m_dDistFromGround;
					}
					else
					{
						bool flag7 = selHSDefineInfo.m_eType == HSType.kDJ_DC || selHSDefineInfo.m_eType == HSType.kDJ_PX || selHSDefineInfo.m_eType == HSType.kDJ_DC3 || selHSDefineInfo.m_eType == HSType.kDJ_PX3 || selHSDefineInfo.m_eType == HSType.kDJ_YC || selHSDefineInfo.m_eType == HSType.kDJ_DZ;
						if (flag7)
						{
							for (int j = 1; j < selHSDefineInfo.m_nFloorNum; j++)
							{
								num2 += selHSDefineInfo.m_matHor.m_dHigh + selHSDefineInfo.m_dNetHigh[j];
							}
							HSDraw.GetUpDownLevel(ref num3, ref num4, num2, doc);
							bool flag8 = num > num2;
							if (flag8)
							{
								selHSDefineInfo.m_dDistFromGround = num - num2;
							}
							else
							{
								bool flag9 = num3 > num2;
								if (flag9)
								{
									selHSDefineInfo.m_dDistFromGround = num3 - num2;
								}
							}
							bool flag10 = selHSDefineInfo.m_dDistFromGround < 10.0;
							if (flag10)
							{
								selHSDefineInfo.m_dDistFromGround = 10.0;
							}
							num2 += selHSDefineInfo.m_dDistFromGround;
						}
						else
						{
							bool flag11 = selHSDefineInfo.m_eType == HSType.kDJ_GJ || selHSDefineInfo.m_eType == HSType.kDJ_SG || selHSDefineInfo.m_eType == HSType.kDJ_SL || selHSDefineInfo.m_eType == HSType.kDJ_ZJ || selHSDefineInfo.m_eType == HSType.kDJ_DB;
							if (flag11)
							{
								double num5 = num2 + selHSDefineInfo.m_dNetHigh[1];
								HSDraw.GetUpDownLevel(ref num3, ref num4, num5, doc);
								bool flag12 = num > num5;
								if (flag12)
								{
									selHSDefineInfo.m_dNetHigh[0] = num - num2;
								}
								else
								{
									bool flag13 = num3 > num5;
									if (flag13)
									{
										selHSDefineInfo.m_dNetHigh[0] = num3 - num2;
									}
								}
								num2 += selHSDefineInfo.m_dNetHigh[0];
							}
							else
							{
								bool flag14 = selHSDefineInfo.m_eType == HSType.kDJ_DG;
								if (flag14)
								{
									bool flag15 = num > num2;
									if (flag15)
									{
										selHSDefineInfo.m_dNetHigh[0] = num - num2;
									}
									else
									{
										bool flag16 = num3 > num2;
										if (flag16)
										{
											selHSDefineInfo.m_dNetHigh[0] = num3 - num2;
										}
									}
									num2 += selHSDefineInfo.m_dNetHigh[0];
									selHSDefineInfo.m_dNetHigh[0] -= selHSDefineInfo.m_dNetWide / 2.0;
									selHSDefineInfo.m_dNetHigh[0] -= selHSDefineInfo.m_dLoopThick;
									selHSDefineInfo.m_dNetHigh[0] -= selHSDefineInfo.m_dGapHor;
								}
								else
								{
									bool flag17 = selHSDefineInfo.m_eType == HSType.kZJ_CB;
									if (flag17)
									{
										selHSDefineInfo.m_dElevation = 0.0;
									}
									else
									{
										bool flag18 = !selHSDefineInfo.IsSupport();
										if (flag18)
										{
											bool flag19 = num > num2;
											if (flag19)
											{
												selHSDefineInfo.m_dNetHigh[0] = num - num2;
											}
											else
											{
												bool flag20 = num3 > num2;
												if (flag20)
												{
													selHSDefineInfo.m_dNetHigh[0] = num3 - num2;
												}
											}
											num2 += selHSDefineInfo.m_dNetHigh[0];
										}
									}
								}
							}
						}
					}
					double num6 = num2 - num;
					num6 = Utils.DoublePrecision(num6, 1);
					selHSDefineInfo.m_dElevationOffset = num6;
					selHSDefineInfo.m_dNetHigh[0] = Utils.DoublePrecision(selHSDefineInfo.m_dNetHigh[0], 1);
				}
			}
		}

		private void AutoAdjustHSSectionSizeByGap(bool bGapHorChanged, bool bGapVerChanged, HSDrawType drawType)
		{
			this.m_secSelectInfo.m_bMirrored = this.m_selHSDefineInfo.m_bMirrored;
			this.m_secSelectInfo.GetSecInfoFromSelPipes();
			this.m_ptBase = Utils.SetPtX(this.m_ptBase, this.m_secSelectInfo.GetSecMidX());
			DlgHSDesign.AutoAdjustHSSectionSizeByDefine(ref this.m_ptBase, ref this.m_dElevation, ref this.m_selHSDefineInfo, this.m_doc, this.m_secSelectInfo, false, drawType, null);
		}

		private void AutoAdjustHSSectionSize(HSDrawType drawType, bool bIncludeSelectSections = false)
		{
			if (bIncludeSelectSections)
			{
				DlgHSDesign.AutoAdjustHSSectionSizeByDefine(ref this.m_ptBase, ref this.m_dElevation, ref this.m_selHSDefineInfo, this.m_doc, this.m_secSelectInfo, bIncludeSelectSections, drawType, null);
			}
			else
			{
				PipeSelect secSelectInfo = new PipeSelect(this.m_uiApp);
				DlgHSDesign.AutoAdjustHSSectionSizeByDefine(ref this.m_ptBase, ref this.m_dElevation, ref this.m_selHSDefineInfo, this.m_doc, secSelectInfo, bIncludeSelectSections, drawType, null);
			}
			this.m_selHSDefineInfo.m_ptBase = this.m_ptBase;
		}

		public static double GetBasePointZValue(HSDefineInfo selHSDefineInfo)
		{
			double highFromBase = selHSDefineInfo.GetHighFromBase();
			double multiFloorsHigh = selHSDefineInfo.GetMultiFloorsHigh();
			double num = multiFloorsHigh + highFromBase;
			double num2 = selHSDefineInfo.m_dElevation;
			num2 += selHSDefineInfo.m_dElevationOffset;
			bool flag = selHSDefineInfo.IsSupport();
			if (flag)
			{
				num2 += num;
			}
			else
			{
				num2 -= num;
				bool flag2 = selHSDefineInfo.m_eType == HSType.kDJ_DG;
				if (flag2)
				{
					num2 -= selHSDefineInfo.m_dLoopDiameter / 2.0 + selHSDefineInfo.m_dLoopThick + selHSDefineInfo.m_dGapHor;
				}
			}
			return num2;
		}

		public static void AutoAdjustHSSectionSizeByDefine(ref XYZ ptBase, ref double dElevation, ref HSDefineInfo selHSDefineInfo, Autodesk.Revit.DB.Document doc, PipeSelect secSelectInfo, bool bSelectPipesSection, HSDrawType drawType, Line lnSectionCut = null)
		{
			List<PipeSectionDef> selSecLst = secSelectInfo.GetSelSecLst();
			bool flag = selSecLst.Count == 0;
			if (flag)
			{
				Level level = Utils.GetLevel(selHSDefineInfo.m_strElevationName, doc);
				bool flag2 = level != null;
				if (flag2)
				{
					selHSDefineInfo.m_dElevation = Utils.feetToMM(level.Elevation);
				}
				dElevation = DlgHSDesign.GetBasePointZValue(selHSDefineInfo);
				ptBase = Utils.SetPtY(ptBase, dElevation);
			}
			else
			{
				secSelectInfo.m_bMirrored = selHSDefineInfo.m_bMirrored;
				bool flag3 = lnSectionCut == null;
				if (flag3)
				{
					secSelectInfo.GetSecInfoFromSelPipes();
				}
				else
				{
					secSelectInfo.GetSecInfoByLine(lnSectionCut, false);
				}
				selSecLst = secSelectInfo.GetSelSecLst();
				List<double> list = new List<double>();
				list = secSelectInfo.GetLevelsElevation(selHSDefineInfo.m_dGapHor, selHSDefineInfo.m_matHor.m_dHigh);
				bool flag4 = bSelectPipesSection && selSecLst.Count == 1 && drawType == HSDrawType.eDrawTypeDrawByPipe;
				double num;
				if (flag4)
				{
					num = selHSDefineInfo.m_dNetWide;
				}
				else
				{
					num = secSelectInfo.GetSecWideTol(selHSDefineInfo.m_dGapVer);
				}
				double secMidX = secSelectInfo.GetSecMidX();
				selHSDefineInfo.m_strElevationName = selSecLst[0].m_strLevelName;
				List<double> list2 = new List<double>();
				bool flag5 = selHSDefineInfo.m_eType != HSType.kZJ_CB;
				if (flag5)
				{
					selHSDefineInfo.m_dNetWide = num;
				}
				selHSDefineInfo.m_dLoopDiameter = selSecLst[0].m_dWide;
				selHSDefineInfo.m_dPXWide = selHSDefineInfo.m_dNetWide / 2.0;
				selHSDefineInfo.m_dHangerDBOffsetDist = 0.0;
				bool flag6 = selHSDefineInfo.IsSupport();
				if (flag6)
				{
					bool flag7 = selHSDefineInfo.m_eType != HSType.kZJ_PX;
					if (flag7)
					{
						for (int i = 1; i < list.Count - 1; i++)
						{
							selHSDefineInfo.m_dNetHigh[i] = list[list.Count - 1 - i] - list[list.Count - 2 - i] - selHSDefineInfo.m_matHor.m_dHigh;
						}
					}
					else
					{
						for (int j = 2; j < list.Count - 1; j++)
						{
							selHSDefineInfo.m_dNetHigh[j - 1] = list[list.Count - 1 - j] - list[list.Count - 2 - j] - selHSDefineInfo.m_matHor.m_dHigh;
						}
						bool flag8 = list.Count > 2;
						if (flag8)
						{
							selHSDefineInfo.m_dPXHigh = list[list.Count - 2] - list[list.Count - 3] - selHSDefineInfo.m_matHor.m_dHigh;
						}
					}
					selHSDefineInfo.m_dElevation = list[list.Count - 2];
					bool flag9 = selHSDefineInfo.m_eType == HSType.kZJ_SJ || selHSDefineInfo.m_eType == HSType.kZJ_XB;
					if (flag9)
					{
						selHSDefineInfo.m_dElevation = list[0];
					}
					else
					{
						bool flag10 = selHSDefineInfo.m_eType == HSType.kZJ_PX;
						if (flag10)
						{
							selHSDefineInfo.m_dElevation = list[list.Count - 2] - selHSDefineInfo.m_dPXHigh - selHSDefineInfo.m_matHor.m_dHigh;
						}
						else
						{
							bool flag11 = selHSDefineInfo.m_eType == HSType.kZJ_CB;
							if (flag11)
							{
								selHSDefineInfo.m_dElevation = list[0] + selHSDefineInfo.m_dGapHor + selSecLst[0].High() / 2.0;
								selHSDefineInfo.m_dElevationOffset = 0.0;
							}
						}
					}
					dElevation = selHSDefineInfo.m_dElevation;
					double num2 = 0.0;
					ptBase = new XYZ(secMidX - num2, selHSDefineInfo.m_dElevation, 0.0);
				}
				else
				{
					selHSDefineInfo.m_dElevation = list[0];
					dElevation = selHSDefineInfo.m_dElevation;
					bool flag12 = bSelectPipesSection && selSecLst.Count == 1 && drawType == HSDrawType.eDrawTypeDrawByPipe;
					if (flag12)
					{
						for (int k = 1; k < list.Count - 1; k++)
						{
							selHSDefineInfo.m_dNetHigh[k] = list[list.Count - 1 - k] - list[list.Count - 2 - k] - selHSDefineInfo.m_matHor.m_dHigh;
						}
					}
					else
					{
						for (int l = 0; l < list.Count - 1; l++)
						{
							selHSDefineInfo.m_dNetHigh[l + 1] = list[l + 1] - list[l] - selHSDefineInfo.m_matHor.m_dHigh;
						}
					}
					bool flag13 = selHSDefineInfo.m_eType == HSType.kDJ_PX;
					if (flag13)
					{
						for (int m = 1; m < list.Count - 1; m++)
						{
							selHSDefineInfo.m_dNetHigh[m] = list[m + 1] - list[m] - selHSDefineInfo.m_matHor.m_dHigh;
						}
						selHSDefineInfo.m_dPXHigh = list[1] - list[0] - selHSDefineInfo.m_matHor.m_dHigh;
						selHSDefineInfo.m_dElevation = list[1];
						selHSDefineInfo.m_dPXWide = selHSDefineInfo.m_dNetWide;
						double dPXWide = secSelectInfo.GetPXDJOffsetWide(list, selHSDefineInfo.m_dGapVer);
						selHSDefineInfo.m_dPXWide = dPXWide;
						bool flag14 = list.Count > 1;
						if (flag14)
						{
							dPXWide = 0.0;
							list2 = secSelectInfo.GetLevelElevationWides(ref dPXWide, new List<double>
							{
								list[1]
							}, selHSDefineInfo.m_dGapVer, selHSDefineInfo.m_matVer.m_dHigh, 0);
							bool flag15 = list2 != null && list2.Count > 0;
							if (flag15)
							{
								selHSDefineInfo.m_dElevation = list[1];
							}
							else
							{
								bool flag16 = list2 == null;
								if (flag16)
								{
									selHSDefineInfo.m_dPXWide = num;
								}
							}
						}
					}
					double dElevation2 = selHSDefineInfo.m_dElevation;
					bool flag17 = selHSDefineInfo.m_eType == HSType.kDJ_DG;
					if (flag17)
					{
						selHSDefineInfo.m_dNetWide = selHSDefineInfo.m_dLoopDiameter;
						dElevation2 = selSecLst[0].m_dElevation;
						selHSDefineInfo.m_dElevation = dElevation2;
					}
					ptBase = new XYZ(secMidX, dElevation2, 0.0);
				}
				bool flag18 = selHSDefineInfo.m_eType == HSType.kZJ_PX && list.Count > 1;
				if (flag18)
				{
					selHSDefineInfo.m_dPXWide = secSelectInfo.GetSecWideTolByElevationUp(selHSDefineInfo.m_dGapVer, list[list.Count - 2]);
					bool flag19 = list.Count < 3;
					if (flag19)
					{
						selHSDefineInfo.m_dNetWide = num * 2.0;
						selHSDefineInfo.m_dPXWide = num;
						ptBase = Utils.SetPtX(ptBase, ptBase.X - num / 2.0);
						selHSDefineInfo.m_dHangerDBOffsetDist = num / 2.0;
					}
					else
					{
						double dStartDist = selHSDefineInfo.m_dPXWide - selHSDefineInfo.m_dGapVer * 2.0;
						selHSDefineInfo.m_dPXWide = secSelectInfo.GetWideInLevelElevationFromDist(list[list.Count - 2], list[list.Count - 3], selHSDefineInfo.m_dGapVer, selHSDefineInfo.m_matVer.m_dHigh, dStartDist);
					}
					bool flag20 = selHSDefineInfo.m_dPXWide > selHSDefineInfo.m_dNetWide;
					if (flag20)
					{
						selHSDefineInfo.m_dPXWide = selHSDefineInfo.m_dNetWide;
					}
				}
				bool flag21 = selHSDefineInfo.m_eType == HSType.kDJ_SG || selHSDefineInfo.m_eType == HSType.kDJ_SL;
				if (flag21)
				{
					double num3 = 0.0;
					list2 = secSelectInfo.GetLevelElevationWides(ref num3, new List<double>
					{
						list[0]
					}, selHSDefineInfo.m_dGapVer, selHSDefineInfo.m_matVer.m_dHigh, 0);
					bool flag22 = list2 != null && list2.Count > 0;
					if (flag22)
					{
						selHSDefineInfo.m_dPXWide = list2[0] + selHSDefineInfo.m_dGapVer - selHSDefineInfo.m_matVer.m_dHigh / 2.0;
					}
					else
					{
						bool flag23 = list2.Count == 0;
						if (flag23)
						{
							selHSDefineInfo.m_dNetWide = num * 2.0;
							selHSDefineInfo.m_dPXWide = num;
							ptBase = Utils.SetPtX(ptBase, ptBase.X - num / 2.0);
							selHSDefineInfo.m_dHangerDBOffsetDist = num / 2.0;
						}
					}
				}
				bool flag24 = selHSDefineInfo.m_eType == HSType.kDJ_PX3;
				if (flag24)
				{
					selHSDefineInfo.m_dElevation = list[0];
					dElevation = selHSDefineInfo.m_dElevation;
					for (int n = 0; n < list.Count - 1; n++)
					{
						selHSDefineInfo.m_dNetHigh[n + 1] = list[n + 1] - list[n] - selHSDefineInfo.m_matHor.m_dHigh;
					}
					selHSDefineInfo.m_dPXHigh = list[1] - list[0] - selHSDefineInfo.m_matHor.m_dHigh;
					selHSDefineInfo.m_dElevation = list[1];
					selHSDefineInfo.m_dPXWide = selHSDefineInfo.m_dNetWide;
					double dPXWide2 = secSelectInfo.GetPXDJOffsetWide(list, selHSDefineInfo.m_dGapVer);
					selHSDefineInfo.m_dPXWide = dPXWide2;
					bool flag25 = list.Count > 2;
					if (flag25)
					{
						dPXWide2 = 0.0;
						list2 = secSelectInfo.GetLevelElevationWides(ref dPXWide2, new List<double>
						{
							list[1]
						}, selHSDefineInfo.m_dGapVer, selHSDefineInfo.m_matVer.m_dHigh, 0);
						bool flag26 = list2 != null && list2.Count > 0;
						if (flag26)
						{
							selHSDefineInfo.m_dOffsetX = list2[0] + selHSDefineInfo.m_dGapVer - selHSDefineInfo.m_matVer.m_dHigh / 2.0;
							selHSDefineInfo.m_dElevation = list[1];
							bool flag27 = selHSDefineInfo.m_dNetWide <= selHSDefineInfo.m_dOffsetX;
							if (flag27)
							{
								selHSDefineInfo.m_dOffsetX /= 2.0;
							}
						}
						else
						{
							bool flag28 = list2 != null && list2.Count == 0;
							if (flag28)
							{
								selHSDefineInfo.m_dPXWide = num;
								selHSDefineInfo.m_dOffsetX = num;
								ptBase = Utils.SetPtX(ptBase, ptBase.X - num / 2.0);
								selHSDefineInfo.m_dHangerDBOffsetDist = num / 2.0;
								bool flag29 = selHSDefineInfo.m_dNetWide <= selHSDefineInfo.m_dOffsetX;
								if (flag29)
								{
									selHSDefineInfo.m_dOffsetX /= 2.0;
								}
							}
						}
					}
					else
					{
						selHSDefineInfo.m_dOffsetX = num / 2.0;
					}
					double dElevation3 = selHSDefineInfo.m_dElevation;
					ptBase = new XYZ(secMidX, dElevation3, 0.0);
				}
				bool flag30 = selHSDefineInfo.m_eType == HSType.kDJ_DC3;
				if (flag30)
				{
					double num4 = 0.0;
					list2 = secSelectInfo.GetLevelElevationWides(ref num4, new List<double>
					{
						list[0]
					}, selHSDefineInfo.m_dGapVer, selHSDefineInfo.m_matVer.m_dHigh, 0);
					bool flag31 = list2 != null && list2.Count > 0;
					if (flag31)
					{
						selHSDefineInfo.m_dOffsetX = list2[0] + selHSDefineInfo.m_dGapVer - selHSDefineInfo.m_matVer.m_dHigh / 2.0;
					}
					else
					{
						bool flag32 = list2 != null && list2.Count == 0;
						if (flag32)
						{
							selHSDefineInfo.m_dNetWide = num * 2.0 + selHSDefineInfo.m_matVer.m_dHigh;
							selHSDefineInfo.m_dPXWide = num;
							selHSDefineInfo.m_dOffsetX = num;
							ptBase = Utils.SetPtX(ptBase, ptBase.X - num / 2.0 - selHSDefineInfo.m_matVer.m_dHigh / 2.0);
							selHSDefineInfo.m_dHangerDBOffsetDist = num / 2.0 + selHSDefineInfo.m_matVer.m_dHigh / 2.0;
						}
					}
				}
				bool flag33 = selHSDefineInfo.m_eType == HSType.kZJ_SJ;
				if (flag33)
				{
					selHSDefineInfo.m_dOffsetX = selHSDefineInfo.m_dNetWide * 2.0 / 3.0;
					selHSDefineInfo.m_dOffsetX = Utils.DoublePrecision(selHSDefineInfo.m_dOffsetX, 0);
				}
				bool flag34 = selHSDefineInfo.m_eType == HSType.kDJ_DB;
				if (flag34)
				{
					double num5 = num / 2.0 + selHSDefineInfo.m_matVer.m_dHigh / 2.0;
					selHSDefineInfo.m_dHangerDBOffsetDist = num5;
					double num6 = ptBase.X - num5;
					ptBase = new XYZ(num6, ptBase.Y, 0.0);
				}
				DlgHSDesign.CalLevelInfoByDef(ref selHSDefineInfo, doc, bSelectPipesSection, drawType);
				selHSDefineInfo.m_dDistFromGround = Utils.DoublePrecision(selHSDefineInfo.m_dDistFromGround, 0);
				selHSDefineInfo.m_dElevationOffset = Utils.DoublePrecision(selHSDefineInfo.m_dElevationOffset, 0);
				selHSDefineInfo.m_dNetWide = Utils.DoublePrecision(selHSDefineInfo.m_dNetWide, 0);
				selHSDefineInfo.m_dPXWide = Utils.DoublePrecision(selHSDefineInfo.m_dPXWide, 0);
				for (int num7 = 0; num7 < 15; num7++)
				{
					selHSDefineInfo.m_dNetHigh[num7] = Utils.DoublePrecision(selHSDefineInfo.m_dNetHigh[num7], 0);
				}
			}
		}

		private void DlgHSDesign_SizeChanged(object sender, EventArgs e)
		{
			bool flag = this.pictureBox != null;
			if (flag)
			{
				this.pictureBox.Refresh();
			}
		}

		protected override void DefWndProc(ref Message m)
		{
			int msg = m.Msg;
			if (msg != 1126)
			{
				base.DefWndProc(ref m);
			}
			else
			{
				this.SelectHSType();
			}
		}

		private static int g_Dlg_X = -1;

		private static int g_Dlg_Y = -1;

		private DrawPreviewer pictureBox;

		private UIApplication m_uiApp;

		private Document m_doc;

		public HSDefineInfo m_selHSDefineInfo;

		private List<CurveInfo> m_lstViewCurves;

		private List<TextNoteInfo> m_lstViewTexts;

		private PenColor m_colorPen;

		private PenColor m_colorText;

		private double m_dFontHigh;

		public HSDrawType m_kDrawType;

		private PipeSelect m_secSelectInfo;

		private HSTypeInfo m_HSTypeManage;

		private HSPropsLst m_hsPropManage;

		private XYZ m_ptBase;

		private double m_dElevation;

		private List<Level> m_listLevel;

		public Level m_curLevel;

		public bool m_bSelectPipesSection;
	}
}
